package itheima.moc.ServerSocketDEMO7;

import java.io.*;
import java.net.Socket;

public class SocketDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 9999);

        OutputStream os = socket.getOutputStream();
        os.write("Hello".getBytes());
        socket.shutdownOutput();

        BufferedReader fr = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line = fr.readLine()) != null) {
            System.out.println(line);
        }

        fr.close();
        os.close();
        socket.close();
    }
}
